{% extends 'template/jhTemplateV4.html'%}

{% block vueTemplate %}

<!--SQL START
-- 以下为 jianghu init 工具生成的参考 SQL，使用后删除
-- 创建 page
INSERT INTO `_page` (`pageId`,`pageName`,`pageType`,`sort`,`operation`,`operationByUserId`,`operationByUser`,`operationAt`) SELECT 'requestFlowManagement','页面','showInMenu','5','jhInsert',NULL,NULL,NULL FROM DUAL WHERE NOT EXISTS (SELECT `pageId` FROM `_page` WHERE `pageId`='requestFlowManagement');

-- 创建 resource
INSERT INTO `_resource` (`accessControlTable`,`resourceHook`,`pageId`,`actionId`,`desc`,`resourceType`,`appDataSchema`,`resourceData`,`requestDemo`,`responseDemo`,`operation`,`operationByUserId`,`operationByUser`,`operationAt`) SELECT NULL,NULL,'requestFlowManagement','selectItemList','✅查询-查询列表','sql','{}','{ \"table\": \"request_flow\", \"operation\": \"select\" }','','','insert',NULL,NULL,NULL FROM DUAL WHERE NOT EXISTS (SELECT `pageId` FROM `_resource` WHERE `pageId`='requestFlowManagement' AND `actionId`='selectItemList');
INSERT INTO `_resource` (`accessControlTable`,`resourceHook`,`pageId`,`actionId`,`desc`,`resourceType`,`appDataSchema`,`resourceData`,`requestDemo`,`responseDemo`,`operation`,`operationByUserId`,`operationByUser`,`operationAt`) SELECT NULL,NULL,'requestFlowManagement','insertItem','✅查询-添加成员','sql','{}','{ \"table\": \"request_flow\", \"operation\": \"insert\" }','','','insert',NULL,NULL,NULL FROM DUAL WHERE NOT EXISTS (SELECT `pageId` FROM `_resource` WHERE `pageId`='requestFlowManagement' AND `actionId`='insertItem');
INSERT INTO `_resource` (`accessControlTable`,`resourceHook`,`pageId`,`actionId`,`desc`,`resourceType`,`appDataSchema`,`resourceData`,`requestDemo`,`responseDemo`,`operation`,`operationByUserId`,`operationByUser`,`operationAt`) SELECT NULL,NULL,'requestFlowManagement','updateItem','✅查询-更新成员','sql','{}','{ \"table\": \"request_flow\", \"operation\": \"update\" }','','','insert',NULL,NULL,NULL FROM DUAL WHERE NOT EXISTS (SELECT `pageId` FROM `_resource` WHERE `pageId`='requestFlowManagement' AND `actionId`='updateItem');
INSERT INTO `_resource` (`accessControlTable`,`resourceHook`,`pageId`,`actionId`,`desc`,`resourceType`,`appDataSchema`,`resourceData`,`requestDemo`,`responseDemo`,`operation`,`operationByUserId`,`operationByUser`,`operationAt`) SELECT NULL,NULL,'requestFlowManagement','deleteItem','✅查询-删除信息','sql','{}','{ \"table\": \"request_flow\", \"operation\": \"delete\" }','','','insert',NULL,NULL,NULL FROM DUAL WHERE NOT EXISTS (SELECT `pageId` FROM `_resource` WHERE `pageId`='requestFlowManagement' AND `actionId`='deleteItem');
SQL END!-->

<script id="app-template" type="text/html">
<div>
<v-app mobile-breakpoint="sm">
  <jh-menu />
  <v-main class="mt-15">
    <!-- 头部内容 >>>>>>>>>>>>> -->
    <div class="jh-page-second-bar px-8">
      <v-row>
        <v-col cols="12" xs="12" sm="12" md="4" xl="3">
          <div class="pt-3 text-h7 font-weight-bold">收付款申请管理
            <!-- 帮助页按钮 -->
            <v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline
            </v-icon>
          </div>
          <v-breadcrumbs class="pb-3 pt-0 pl-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
        </v-col>
        <!-- 搜索条件表单 >>>>>>>> -->
        <!-- 申请单状态 -->

        <v-col cols="12" xs="12" sm="12" md="8" xl="9">
          <v-row class="jh-backend-form-container justify-end ma-0 py-1 pb-xs-2">
            <v-col cols="12" md="3" class="pa-xs-0 pb-2 pl-1 pl-xs-1">
              <v-autocomplete clearable v-model="serverSearchInput.ticketStatus" color="success" prefix="状态：" class="jh-v-input bg-white" :items="constantObj.ticketStatus" dense filled single-line></v-autocomplete>
            </v-col>
            <!-- <v-col cols="12" xs="6" sm="6" md="4" xl="3" class="pa-xs-0 pb-2 pl-1 pl-xs-1">
              <v-select v-model="serverSearchInput.gender" color="success" prefix="性别：" class="jh-v-input bg-white" :items="constantObj.gender" dense filled single-line></v-select>
            </v-col> -->
            <v-btn class="jh-backend-search-btn elevation-0 ml-0 mt-3" color="success" small @click="doUiAction('getTableData')">
              查询
            </v-btn>
          </v-row>
        </v-col>
        <!-- <<<<<<<< 搜索条件表单 -->
      </v-row>
    </div>
    <!-- <<<<<<<<<<<<< 头部内容 -->

    <div class="jh-page-body-container px-8">
      <!-- 页面内容 >>>>>>>>>>>>> -->
      <v-card class="rounded-lg">
        <v-row class="ma-0 pa-4">
          <v-spacer></v-spacer>
          <!-- 搜索过滤 -->
          <v-col cols="12" xs="8" sm="4" md="3" xl="2" class="pa-0">
            <v-text-field color="success" v-model="searchInput" prefix="搜索：" class="jh-v-input" dense filled single-line></v-text-field>
          </v-col>
        </v-row>
        <!-- 表格 -->
        <v-data-table
          :headers="headers"
          :items="tableData"
          :search="searchInput"
          :footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页', itemsPerPageAllText: '所有'}"
          :items-per-page="-1"
          mobile-breakpoint="0"
          :loading="isTableLoading"
          checkbox-color="success"
          :class="{'zebraLine': isTableZebraLineShown }"
          fixed-header
          class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
          <template v-slot:item.operationAt="{ item }">{{item.operationAt | dateFormat }}</template>
          <!-- 表格操作按钮 -->
          <template v-slot:item.action="{ item }">
            <!-- <span role="button" class="success--text font-weight-medium font-size-2 mr-2" @click="doUiAction('startUpdateItem', item)">
              <v-icon size="16" class="success--text">mdi-note-edit-outline</v-icon>修改
            </span>
            <span role="button" class="success--text font-weight-medium font-size-2 mr-2" @click="doUiAction('deleteItem', item)">
              <v-icon size="16" class="success--text">mdi-trash-can-outline</v-icon>删除
            </span> -->
            <span role="button" class="warning--text font-weight-medium font-size-2" @click="doUiAction('startExamineAndApprove', item)" v-if="item.ticketStatus == '待处理'">
              <v-icon size="16" class="warning--text"> mdi-check-decagram-outline</v-icon>处理
            </span>
            <span role="button" class="success--text font-weight-medium font-size-2" v-else>
              已处理
            </span>
          </template>
          <!-- 没有数据 -->
          <template v-slot:loading>
            <div class="jh-no-data">数据加载中</div>
          </template>
          <template v-slot:no-data>
            <div class="jh-no-data">暂无数据</div>
          </template>
          <template v-slot:no-results>
            <div class="jh-no-data">暂无数据</div>
          </template>
          <template v-slot:item.ticketContentRequest="{ item }">
            <div v-for="productName of item.ticketRequestName" style="white-space: nowrap">{{productName}}</div>
          </template>
          <template v-slot:item.ticketStatus="{ item }">
            <v-chip dark x-small :color="getApplyStatusColor(item.ticketStatus)">
              {{item.ticketStatus}}
            </v-chip>
          </template>
          <!-- 表格分页 -->
          <template v-slot:footer.page-text="pagination">
            <span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
            <span class="ml-1">共{{pagination.itemsLength}}条</span>
          </template>
        </v-data-table>
      </v-card>
      <!-- 处理抽屉 -->
      <v-navigation-drawer v-if="isExamineDrawerShow" v-model="isExamineDrawerShow" :permanent="isExamineDrawerShow" fixed temporary right width="80%" class="elevation-24">
        <v-form ref="createForm" lazy-validation>
          <!-- 抽屉标题 -->
          <v-row>
            <span class="text-subtitle-1 font-weight-medium pa-6 pl-7">新增信息</span>
          </v-row>
          <!-- 抽屉表单 -->
          <!-- <v-text-field class="jh-v-input" dense single-line filled v-model="createItem.xxxId" :rules="validationRules.requireRules"></v-text-field> -->
          <v-row class="mt-0 px-4">
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">申请id</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.ticketId"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">收款账户卡号</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.payeeNumber"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">付款账户卡号</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.payerNumber"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">流水金额</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.flowAmount"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">流水类型（收款/付款）</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.flowType"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">流水方式（银行/现金）</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.flowMode"></v-text-field>
            </v-col>
             
            <v-col cols="12" sm="12" md="12">
              <span class="jh-input-label">备注</span>
              <v-textarea class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.remark"></v-textarea>
            </v-col>
             
            <!-- <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">发票信息ID（发票抬头、编号、开票日期、项目明细、金额、税率、税额、发票总额、发票备注）</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.invoiceId"></v-text-field>
            </v-col> -->
             
            <!-- <v-col cols="12" sm="12" md="4">
              <span class="jh-input-label">filePath</span>
              <v-text-field class="jh-v-input" dense single-line filled v-model="examineAndApproveActionData.filePath"></v-text-field>
            </v-col>
          </v-row> -->

          <!-- 抽屉操作按钮 -->
          <v-row class="justify-end mx-0 mt-8 px-6">
            <v-btn color="success" @click="doUiAction('examineAndApprove')" small>保存</v-btn>
            <v-btn class="elevation-0 ml-2" @click="isExamineDrawerShow = false" small>取消</v-btn>
          </v-row>
        </v-form>
        <!-- 抽屉关闭按钮 -->
        <v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isExamineDrawerShow = false">
          <v-icon>mdi-close</v-icon>
        </v-btn>
      </v-navigation-drawer>
    </div>

    <!-- 帮助页抽屉 >>>>>>>>>>>>> -->
    <v-navigation-drawer v-if="isHelpPageDrawerLoaded" v-model="isHelpPageDrawerShown" :permanent="isHelpPageDrawerShown" fixed temporary right width="80%" class="elevation-24">
      <iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#404.md`" width="100%" height="100%"></iframe>
      <v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isHelpPageDrawerShown = false">
        <v-icon>mdi-close</v-icon>
      </v-btn>
    </v-navigation-drawer>
    <!-- <<<<<<<<<<<<< 帮助页抽屉 -->

  </v-main>
</v-app>

<jh-toast />
<jh-mask />
<jh-confirm-dialog />
</div>
</script>

<div id="app">
</div>

{% endblock %}

{% block vueScript %}
{% include 'filter/vueFilters.html' %}
{% include 'common/jianghuJs/fixedTableHeightV4.html' %}
<script type="module">
  new Vue({
    el: '#app',
    template: '#app-template',
    vuetify: new Vuetify(),
    data: () => ({
      // 处理判断
      contractId: null,
      carId: null,
      ticketContentRequest: {},
      // 审批抽屉
      isExamineDrawerShow: false,
      examineAndApproveActionData: {},
      // 面包屑
      breadcrumbs: [
        {
          text: '首页',
          disabled: true,
        },
        {
          text: '收付款申请管理',
          disabled: true,
        }
      ],
      isHelpPageDrawerShown: false,
      isHelpPageDrawerLoaded: false,
      isMobile: window.innerWidth < 500,
      // 表格相关数据
      isTableZebraLineShown: true,
      validationRules: {
        requireRules: [
          v => !!v || 'This is required',
        ],
      },
      // 下拉选项
      constantObj: {
        gender: [{ "value": null, "text": "全部" }, { "value": "male", "text": "男" }, { "value": "female", "text": "女" }],
        ticketStatus: [
          { text: '全部', value: null },
          { text: '申请', value: '待处理' },
          { text: '完成', value: '已处理' },
        ]
      },
      serverSearchInput: {
        ticketStatus: '待处理',
      },
      searchInput: null,
      isTableLoading: true,
      tableData: [],
      headers: [
        { text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
        { text: "工单ID", value: "ticketId", width: 120 },
        { text: "合同ID", value: "ticketBizId", width: 120 },
        { text: "工单类型", value: "ticketType", width: 120 },
        { text: "工单状态", value: "ticketStatus", width: 120 },
        // { text: "工单描述", value: "ticketDesc", width: 120 },
        { text: "申请内容", value: "ticketContentRequest", width: 120 },
        // { text: "完成内容", value: "ticketContent", width: 120 },
        { text: "总金额", value: "ticketAmount", width: 120 },
        { text: "申请时间", value: "ticketRequestAt", width: 120 },
        { text: "申请人Id", value: "ticketRequestByUserId", width: 120 },
        { text: "申请人", value: "ticketRequestByUser", width: 120 },
        { text: "处理时间", value: "ticketStatusAt", width: 120 },
        { text: "处理描述", value: "ticketStatusDesc", width: 120 },
        { text: "处理人Id", value: "ticketStatusByUserId", width: 120 },
        { text: "处理人", value: "ticketStatusByUser", width: 120 },
        // { text: "filePath", value: "filePath", width: 120 },
        { text: "操作者", value: "operationByUser", width: 120 },
        { text: "操作时间", value: "operationAt", width: 250 },
      ],

      isCreateDrawerShown: false,
      createItem: {},
      createActionData: {},
      isUpdateDrawerShown: false,
      updateItem: {},
      updateItemId: null,
      updateActionData: {},
      deleteItem: {},
      deleteItemId: null

    }),
    watch: {
      isHelpPageDrawerShown(val) {
        if (val && !this.isHelpPageDrawerLoaded) {
          this.isHelpPageDrawerLoaded = true;
        }
      },
    },
    async created() {
    },
    mounted() {
      this.doUiAction('getTableData');
    },
    methods: {
      async doUiAction(uiActionId, uiActionData) {
        switch (uiActionId) {
          case 'startExamineAndApprove':
            await this.prepareExamineFormData(uiActionData);
            await this.openExamineDrawer();
            break;
          case 'examineAndApprove':
            await this.confirmCreateItemDialog();
            await this.doCreateRunningAccount();
            await this.closeExamineDrawer();
            await this.doExamineAndApprove(uiActionData);
            await this.updateTicketStatus();
            await this.getTableData();
            break;
          case 'getTableData':
            await this.getTableData();
            break;
          case 'startCreateItem':
            await this.prepareCreateFormData();
            await this.openCreateDrawer();
            break;
          case 'createItem':
            await this.prepareCreateValidate();
            await this.confirmCreateItemDialog();
            await this.prepareDoCreateItem();
            await this.doCreateItem();
            await this.closeCreateDrawer();
            await this.getTableData();
            break;
          case 'startUpdateItem':
            await this.prepareUpdateFormData(uiActionData);
            await this.openUpdateDrawer();
            break;
          case 'updateItem':
            await this.prepareUpdateValidate();
            await this.confirmUpdateItemDialog();
            await this.prepareDoUpdateItem();
            await this.doUpdateItem();
            await this.closeUpdateDrawer();
            await this.getTableData();
            break;
          case 'deleteItem':
            await this.prepareDeleteFormData(uiActionData);
            await this.confirmDeleteItemDialog();
            await this.prepareDoDeleteItem();
            await this.doDeleteItem();
            await this.clearDeleteItem();
            await this.getTableData();
            break;
          default:
            console.error("[doUiAction] uiActionId not find", { uiActionId });
            break;
        }
      },
      _extractRequestNames(ticketContentRequest) {
        const ticketRequestName = ticketContentRequest.map(row => {
          return row.requestType;
        })
        return ticketRequestName;
      },
      getApplyStatusColor(status) {
        switch (status) {
          case '待处理':
            return 'blue';
          case '已处理':
            return 'green';
        }
      },
      async closeExamineDrawer() {
        this.isExamineDrawerShow = false
      },
      async openExamineDrawer() {
        this.isExamineDrawerShow = true
      },
      async prepareExamineFormData(uiActionData) {
        this.examineAndApproveActionData = {}
        if (uiActionData.ticketContentRequest) {
          // 流水表不包含申请项，放到该字段以便传到service
          this.ticketContentRequest = uiActionData.ticketContentRequest
          this.contractId = uiActionData.ticketBizId
        }
        // 取出申请金额、流水类型、流水方式直接放入审批表单中，即流水表的相关字段
        this.examineAndApproveActionData.ticketId = uiActionData.ticketId
        this.examineAndApproveActionData.flowAmount = uiActionData.ticketAmount
        this.examineAndApproveActionData.flowType = uiActionData.ticketType
      },

      async doCreateRunningAccount() {
        await window.jhMask.show();
        await window.vtoast.loading("处理中");
        try {
          await window.jianghuAxios({
            data: {
              appData: {
                pageId: 'flowManagement',
                actionId: 'insertItem',
                actionData: this.examineAndApproveActionData,
                idGenerate: {
                  type: "idSequence",
                  prefix: "LS",
                  bizId: "flowId",
                  tableName: "flow",
                }
              }
            }
          })
          await window.jhMask.hide();
          await window.vtoast.success("处理完成");
        } catch (error) {
          console.log(error)
        }
      },

      /**
       * 开始处理，将申请表中的申请项目列表中的租金、押金、管理费写入流水表中的对应字段
       * 1. 维修、保养、保险、违章的费用不用记录在订单表
       * 2. 租金、押金、管理费的费用要记录在订单表
       * 3. 保险需要付款之后直接更新保险表
       * 4. 保养、维修需要修改车辆状态
       */
      async doExamineAndApprove() {
        let request = this.ticketContentRequest
        // 租金、押金、管理费的费用要记录在订单表
        if (request.includes("租金") || request.includes("押金") || request.includes("管理费")) {
          await window.jianghuAxios({
            data: {
              appData: {
                pageId: 'requestFlowManagement',
                actionId: 'examineAndApprove',
                actionData: {
                  ...this.examineAndApproveActionData,
                  // 将ticketContentRequest传入后端
                  ticketContentRequest: request,
                  // 合同id传到service用来查询当前订单的现有金额
                  contractId: this.contractId,
                  // flowAmount: this.examineAndApproveActionData.flowAmount
                },
                idGenerate: {
                  type: "idSequence",
                  prefix: "LS",
                  bizId: "flowId",
                  tableName: "flow",
                }
              }
            }
          })
        }
        // 不用更新订单表，只需要更新违章表

        // 不用更新订单表，但要更新保险表的状态

        // 维修、保养、违章不需要额外处理,都是在页面手动点击“完成”

      },

      //更新ticket记录的状态
      async updateTicketStatus() {
        await window.jianghuAxios({
          data: {
            appData: {
              pageId: 'ticketManagement',
              actionId: 'updateItem',
              actionData: {
                ticketStatus: "已处理",
                ticketStatusByUser: `<$ ctx.userInfo.username $>`,
                ticketStatusByUserId: `<$ ctx.userInfo.userId $>`,
                ticketStatusAt: dayjs().format("YYYY-MM-DD hh:mm:ss")
              },
              where: { ticketId: this.examineAndApproveActionData.ticketId }
            }
          }
        })
      },
      /**
       * 获取表格数据
       */
      async getTableData() {
        this.isTableLoading = true;
        const backendSearchData = _.pickBy(this.serverSearchInput, (fieldValue, fieldKey) => {
          if (fieldValue !== null && fieldValue !== '') {
            return true;
          }
        });
        const whereIn = _.pickBy({
          ticketType: ['付款申请', '收款申请'],
        }, _.identity)

        const rows = (await window.jianghuAxios({
          data: {
            appData: {
              pageId: 'ticketManagement',
              actionId: 'selectItemList',
              actionData: {},
              where: backendSearchData,
              whereIn,
              orderBy: [{ column: 'operationAt', order: 'desc' }]
            }
          }
        })).data.appData.resultData.rows;

        this.tableData = rows.map(row => {
          const ticketContentRequest = JSON.parse(row.ticketContentRequest)
          row.ticketRequestName = this._extractRequestNames(ticketContentRequest)
          return row
        });
        this.isTableLoading = false;
      },
      // ---------- 新增数据 uiAction >>>>>>>>>> --------
      async prepareCreateFormData() {
        this.createItem = {};
      },

      async openCreateDrawer() {
        this.isCreateDrawerShown = true;
      },

      async prepareCreateValidate() {
        if (await this.$refs.createForm.validate()) {
          return true;
        }
        throw new Error("请完善表单信息")
      },

      async confirmCreateItemDialog() {
        if (await window.confirmDialog({ title: "新增", content: "确定新增吗？" }) === false) {
          throw new Error("[confirmCreateFormDialog] 否");
        }
      },

      prepareDoCreateItem() {
        const { id, ...data } = this.createItem;
        this.createActionData = data;
      },

      async doCreateItem() {
        await window.jhMask.show();
        await window.vtoast.loading("新增数据");
        await window.jianghuAxios({
          data: {
            appData: {
              pageId: 'requestFlowManagement',
              actionId: 'insertItem',
              actionData: this.createActionData
            }
          }
        })
        await window.jhMask.hide();
        await window.vtoast.success("新增数据成功");
      },
      async closeCreateDrawer() {
        this.isCreateDrawerShown = false;
        this.createItem = {};
        this.createActionData = null;
      },
      // ---------- <<<<<<<<<<< 新增数据 uiAction ---------
      // ---------- 修改数据 uiAction >>>>>>>>>>>> --------
      async prepareUpdateFormData(funObj) {
        this.updateItem = _.cloneDeep(funObj);
      },

      async openUpdateDrawer() {
        this.isUpdateDrawerShown = true;
      },

      async prepareUpdateValidate() {
        if (await this.$refs.updateForm.validate()) {
          return true;
        }
        throw new Error("请完善表单信息")
      },

      async confirmUpdateItemDialog() {
        if (await window.confirmDialog({ title: "修改", content: "确定修改吗？" }) === false) {
          throw new Error("[confirmUpdateItemDialog] 否");
        }
      },

      async prepareDoUpdateItem() {
        const { id, ...data } = this.updateItem;
        this.updateItemId = id;
        this.updateActionData = data;
      },

      async doUpdateItem() {
        await window.jhMask.show();
        await window.vtoast.loading("修改数据");
        await window.jianghuAxios({
          data: {
            appData: {
              pageId: 'requestFlowManagement',
              actionId: 'updateItem',
              actionData: this.updateActionData,
              where: { id: this.updateItemId }
            }
          }
        })

        await window.jhMask.hide();
        await window.vtoast.success("修改数据成功");
      },

      async closeUpdateDrawer() {
        this.isUpdateDrawerShown = false;
        this.updateItem = {};
        this.updateActionData = null;
        this.updateItemId = null;
      },
      // ---------- <<<<<<<<<<< 修改数据 uiAction ---------
      // ---------- 删除数据 uiAction >>>>>>>>>>>> --------
      async prepareDeleteFormData(funObj) {
        this.deleteItem = _.cloneDeep(funObj);
      },
      async confirmDeleteItemDialog() {
        if (await window.confirmDialog({ title: "删除", content: "确定删除吗？" }) === false) {
          throw new Error("[confirmDeleteItemDialog] 否");
        }
      },
      async prepareDoDeleteItem() {
        const { id } = this.deleteItem;
        this.deleteItemId = id;
      },
      async doDeleteItem() {
        await window.vtoast.loading("删除数据");
        await window.jianghuAxios({
          data: {
            appData: {
              pageId: 'requestFlowManagement',
              actionId: 'deleteItem',
              actionData: {},
              where: { id: this.deleteItemId }
            }
          }
        });
        await window.vtoast.success("删除数据成功");
      },
      async clearDeleteItem() {
        this.deleteItem = {};
        this.deleteItemId = null;
      }
      // ---------- <<<<<<<<<<< 删除数据 uiAction ---------
    }
  })
</script>

<style scoped="">
</style>
{% endblock %}
